# Makefile for data files
# Copyright (C) 2002-2006 Olivier Sessink <olivier@bluefish.openoffice.nl>

PACKAGE = @PACKAGE@
VERSION = @VERSION@

SHELL = /bin/sh

top_srcdir = @top_srcdir@
top_builddir = @top_srcdir@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
datadir = @datadir@
datarootdir = @datarootdir@
pkgdatadir = @pkgdatadir@
localedir = $(datadir)/locale

GNOME1MENU=@GNOME1MENU@
FDMENU=@FDMENU@
FDMIME=@FDMIME@
UPDATE_DESKTOP=@UPDATE_DESKTOP@
UPDATE_MIME=@UPDATE_MIME@
GMIMEINFO=@GMIMEINFO@
GAPPREG=@GAPPREG@
ICONPATH=@ICONPATH@
INSTALLDATA=@INSTALLDATA@
HAVE_GNOME_VFS=@HAVE_GNOME_VFS@

INSTALL = @INSTALL@
INSTALL_DIR = $(INSTALL) -d -m 755 
INSTALL_DATA = ${INSTALL} -m 644

DEFAULTFILES = highlighting.default filetypes.default encodings.default custom_menu.default custom_menu.fr.default custom_menu.de.default
FUNCREFFILES = funcref_html.xml funcref_php.xml funcref_css.xml funcref_python.xml
.SUFFIXES: .in .default

.in.default:
	sed -e 's!PKGDATADIR!$(pkgdatadir)!' < $< > $@

all: $(DEFAULTFILES)
	sed -e 's!ICONDIR!$(ICONPATH)!' < bluefish.desktop.in > bluefish.desktop
	sed -e 's!ICONDIR!$(ICONPATH)!' < bluefish-project.desktop.in > bluefish-project.desktop
	if test "x${HAVE_GNOME_VFS}" = "x1" ; then \
		sed -e 's!EXPECT_URIS!true!' -e 's!SUPPORTED_URI_SCHEMES!file,http,ftp,sftp,smb!' < bluefish.applications.in > bluefish.applications ;\
	else \
		sed -e 's!EXPECT_URIS!false!' -e 's!SUPPORTED_URI_SCHEMES!!' < bluefish.applications.in > bluefish.applications ;\
	fi

install-gnome1-menu:
	$(INSTALL_DIR) $(DESTDIR)$(GNOME1MENU)
	$(INSTALL_DATA) bluefish.desktop $(DESTDIR)$(GNOME1MENU)
	$(INSTALL_DATA) bluefish-project.desktop $(DESTDIR)$(GNOME1MENU)

install-fdmenu:
	$(INSTALL_DIR) $(DESTDIR)$(FDMENU)
	$(INSTALL_DATA) bluefish.desktop $(DESTDIR)$(FDMENU)
	$(INSTALL_DATA) bluefish-project.desktop $(DESTDIR)$(FDMENU)

install-update-menu:
	$(UPDATE_DESKTOP)

install-fdmime:
	$(INSTALL_DIR) $(DESTDIR)$(FDMIME)/packages
	$(INSTALL_DATA) bluefish.xml $(DESTDIR)$(FDMIME)/packages

install-update-mime:
	$(UPDATE_MIME) $(FDMIME)

install-gnome-2.4-mime:
	$(INSTALL_DIR) $(DESTDIR)$(GMIMEINFO)
	$(INSTALL_DATA) bluefish.mime $(DESTDIR)$(GMIMEINFO)
	$(INSTALL_DATA) bluefish.keys $(DESTDIR)$(GMIMEINFO)

install-gnome-2.4-appreg:
	$(INSTALL_DIR) $(DESTDIR)$(GAPPREG)
	$(INSTALL_DATA) bluefish.applications $(DESTDIR)$(GAPPREG)

install-icon:
	$(INSTALL_DIR) $(DESTDIR)$(ICONPATH)
	$(INSTALL_DATA) gnome-application-bluefish.png $(DESTDIR)$(ICONPATH)/gnome-mime-application-bluefish-project.png

install: all $(INSTALLDATA)
	$(INSTALL_DIR) $(DESTDIR)$(pkgdatadir)
	for file in $(DEFAULTFILES) ; do \
		$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir) ;\
	done
	for file in $(FUNCREFFILES) ; do \
		$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir) ;\
	done

uninstall:
	rm -f $(FDMIME)/packages/bluefish.xml
	rm -f $(GMIMEINFO)/bluefish.mime
	rm -f $(GMIMEINFO)/bluefish.keys
	rm -f $(GAPPREG)/bluefish.applications
	rm -f $(GNOME1MENU)/bluefish.desktop
	rm -f $(FDMENU)/bluefish.desktop
	rm -f $(FDMENU)/bluefish-project.desktop
	rm -f $(ICONPATH)/gnome-mime-application-bluefish-project.png
	@for file in $(DEFAULTFILES) ; do \
		rm -f $(pkgdatadir)$$file ;\
	done
	@for file in $(FUNCREFFILES) ; do \
		rm -f $(pkgdatadir)$$file ;\
	done

clean:
	rm -f *.default
	rm -f bluefish.desktop
	rm -f bluefish-project.desktop
	rm -f bluefish.applications

distclean: clean
	rm -f Makefile *.rej *.orig *~
